package com.dbuil.bleshoes.ui.activity;



import com.blankj.utilcode.util.ToastUtils;
import com.dbuil.bleshoes.R;
import com.dbuil.bleshoes.base.BaseActivity;
import com.dbuil.bleshoes.ui.view.WheelView;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xui.widget.picker.widget.OptionsPickerView;
import com.xuexiang.xui.widget.picker.widget.builder.OptionsPickerBuilder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;


/**
 * 上下滚动选择
 */
public class SelectTargetActivity extends BaseActivity {
    @BindView(R.id.wheel)
    WheelView wheel;

    @Override
    public int getLayoutId() {
        return R.layout.activity_selecttarget;
    }

    @Override
    public void initData() {
        super.initData();

        initSelect();
        //initSelect2();
    }

    private String[] mSexOption;
    private int sexSelectOption = 0;
    private void initSelect2() {
        mSexOption = ResUtils.getStringArray(R.array.sex_option);
        OptionsPickerView pvOptions = new OptionsPickerBuilder(this, (v, options1, options2, options3) -> {

            sexSelectOption = options1;
            return false;
        })
                .setTitleText("")
                .setSelectOptions(sexSelectOption)
                .isDialog(true)
                .build();
        pvOptions.setPicker(mSexOption);
        pvOptions.show();
    }

    private void initSelect() {

        wheel.setOffset(2);// 对话框中当前项上面和下面的项数
        List<String> dataList=new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            dataList.add("haha"+i);
        }
        wheel.setItems(dataList);// 设置数据源
        wheel.setSeletion(2);// 默认选中第三项

        wheel.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
            @Override
            public void onSelected(int selectedIndex, String item) {

                ToastUtils.showLong(item);
            }
        });
    }
}
